FROM php:7.1.3-fpm
#ADD sources.list /etc/apt/sources.list

# mysql pdo_mysql gd curl swoole memcached redis zip
RUN cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime &&\
    echo "Asia/Shanghai" > /etc/timezone
RUN mv /etc/apt/sources.list /etc/apt/sources.list.bak && \
    echo "deb http://mirrors.163.com/debian/ jessie main non-free contrib" >/etc/apt/sources.list && \
    echo "deb http://mirrors.163.com/debian/ jessie-proposed-updates main non-free contrib" >>/etc/apt/sources.list && \
    echo "deb-src http://mirrors.163.com/debian/ jessie main non-free contrib" >>/etc/apt/sources.list && \
    echo "deb-src http://mirrors.163.com/debian/ jessie-proposed-updates main non-free contrib" >>/etc/apt/sources.list

RUN apt-get update && apt-get install -y \
    inetutils-ping \
    vim \
    git \
    wget \
    zlib1g-dev \
    libfreetype6-dev \
    libmemcached-dev \
    libjpeg62-turbo-dev \
    libmcrypt-dev \
    libpng12-dev \
    libz-dev \
    # 官方 PHP 镜像内置命令，安装 PHP 依赖
    && docker-php-ext-configure gd \
        --with-gd \
        --with-freetype-dir=/usr/include/ \
        --with-png-dir=/usr/include/ \
        --with-jpeg-dir=/usr/include/ \
    && docker-php-ext-install \
        zip \
        gd \
        pdo_mysql \
        mysqli \
        mbstring \
        bcmath \
    # 官方pecl 安装 PHP 依赖
    && pecl install -n -s swoole \
    docker-php-ext-enable swoole \
    && pecl install -o -f redis \
    docker-php-ext-enable redis \
    && pecl install memcached \
    docker-php-ext-enable memcached \
    # 用完包管理器后安排打扫卫生可以显著的减少镜像大小
    && apt-get clean \
    && apt-get autoclean \
    && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

RUN echo "alias ll='ls $LS_OPTIONS -l'" >> /root/.bashrc 

ADD composer.phar /usr/local/bin/composer
RUN chmod 755 /usr/local/bin/composer
